﻿using System;
using System.Windows.Forms;
using TpOffice.Forms;
using TecBaseObjects.Objects;
using TecContracts;
using TecData.Manager;

namespace TpOffice {
    static class Program {
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        static void Main() {
            try {
                TecUserObj u = TecUserDataManager.LoadTecUser(Environment.UserName);
                if (u == null) {
                    MessageBox.Show("Angemeldeter User ist nicht als Tec-Office-User angelegt!", "Tec-Office", MessageBoxButtons.OK);
                    return;
                }
                Contracts.SetMyUser(u);
                TecUserDataManager.SaveUserLogin(u.UserID, u.LoginTime, u.ComputerName);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            } catch (Exception ex) {
                MessageBox.Show("Fehler während Ausführung. (" + ex.Message + ")", "Tec-Office", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
